The present invention relates generally to data processing systems and, more particularly, to the automatic generation of Fortran 90 interfaces to Fortran 77 code.
Before 1990, programmers wrote enormous amounts of code in the Fortran 77 (F77) programming language, which is a fixed parameter language, meaning that each call to a particular subprogram (e.g., a subroutine or a function) contains the same list of parameters. For example, the subprogram SASUM (N, A, Inca) requires three parameters, each of which must be specified every time the subprogram is called. In this example, xe2x80x9cNxe2x80x9d indicates the length of A, xe2x80x9cAxe2x80x9d is an array pointer, and xe2x80x9cIncaxe2x80x9d indicates the stride of A, which is the relative offset within the array for each element to be operated upon. The SASUM subprogram sums the elements of array A at the Inca stride. Thus, for example, if the stride were 2, every second element (e.g., elements A[1], A[3], A[5], etc.) would be summed.
In 1990, the Fortran 90 (F90) language was developed as an improvement over the F77 language by providing a number of additional features, including optional parameters and parameter checking. The use of optional parameters allows a programmer to use different parameter lists to invoke the same subprogram. For example, the following three subprogram calls invoke the same subprogram, even though the number of parameters differs:
Total=SASUM (grades)
Total=SASUM (N, grades)
Total=SASUM (N, grades, Inca)
F90""s parameter checking feature determines whether the types of the parameters are appropriate, whether the number of parameters in the parameter list is appropriate, and whether the shape of the parameters is appropriate. The xe2x80x9cshapexe2x80x9d of a parameter refers to the dimensionality of the parameter. For example, a two-dimensional array has a shape of 2D.
Although F90 provides a number of beneficial features, because there is so much existing code written in F77, it is cost prohibitive to rewrite all of the F77 code. Therefore, it is desirable to facilitate the use of F77 code from F90 code.
In accordance with methods and systems consistent with the present invention, a system that automatically generates F90 interfaces to F77 code is provided. These interfaces provide for the use of optional parameters and, because they are written in F90, also allow for parameter checking. These interfaces are automatically generated to allow a programmer to reap the benefits of F90 calling without having to rewrite the F77 underlying code.
In accordance with an implementation of methods consistent with the present invention, a method is provided in a data processing system that receives F77 source code and that automatically generates a F90 interface to the F77 source code.
In accordance with another implementation, a method is provided in a data processing system having source code with a subprogram having specified parameters. The method reads the source code, where the source code is written in a language where the specified parameters are required parameters such that a value for each specified parameter is required to be provided when the subprogram is invoked. Further, the method generates a stub routine that invokes the subprogram and that facilitates use of a missing value for at least one of the specified parameters.
In yet another implementation, a method is provided in a data processing system with a subprogram written in a fixed parameter language such that the subprogram has a required set of parameters requiring values when the subprogram is invoked. The method invokes a first stub routine with a first plurality of parameter values, the first stub routine using the first parameter values to generate the values for the required set of parameters and invoking the subprogram with the values for the required set of parameters. Further, the method invokes a second stub routine with a second plurality of parameter values, the second stub routine using the second parameter values to generate the values for the required set of parameters and invoking the subprogram with the values for the required set of parameters. The second parameter values have a different number than the first parameter values.
In accordance with an implementation of systems consistent with the present invention, a computer-readable memory device encoded with a program having instructions for execution by a processor is provided. The program comprises fixed parameter code with a subprogram having a plurality of required parameters requiring values at invocation. The program also comprises a stub routine that receives a set of parameter values and creates the values for the required parameters from the received set of parameter values to invoke the subprogram, where the received set of parameter values lacks at least one of the values for the required parameters.
In another implementation of systems consistent with the present invention, a data processing system is provided. This data processing system contains a storage device and a processor. The storage device comprises fixed parameter source code with a subprogram having a plurality of required parameters that require values when the subprogram is invoked and an interface generator that reads the subprogram and that generates an interface file with indications of characteristics of the required parameters. The storage device also comprises a stub generator that reads the interface file and that generates a plurality of stubs for the subprogram. Each of the stubs receives a set of parameter values, generates the parameters from the received set of parameter values, and invokes the subprogram with the values for the required parameters. The received set of parameter values for at least one of the stub routines lacks the value for at least one of the required parameters. The processor runs the interface generator and the stub generator.